package com.ruoyi.parking.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.parking.domain.SmartLevel;
import com.ruoyi.parking.service.ISmartLevelService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 楼层管理Controller
 * 
 * @author ruoyi
 * @date 2025-03-21
 */
@RestController
@RequestMapping("/level")
public class SmartLevelController extends BaseController
{
    @Autowired
    private ISmartLevelService smartLevelService;

    /**
     * 查询楼层管理列表
     */
    @RequiresPermissions("parking:level:list")
    @GetMapping("/list")
    public TableDataInfo list(SmartLevel smartLevel)
    {
        startPage();
        List<SmartLevel> list = smartLevelService.selectSmartLevelList(smartLevel);
        return getDataTable(list);
    }

    /**
     * 导出楼层管理列表
     */
    @RequiresPermissions("parking:level:export")
    @Log(title = "楼层管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SmartLevel smartLevel)
    {
        List<SmartLevel> list = smartLevelService.selectSmartLevelList(smartLevel);
        ExcelUtil<SmartLevel> util = new ExcelUtil<SmartLevel>(SmartLevel.class);
        util.exportExcel(response, list, "楼层管理数据");
    }

    /**
     * 获取楼层管理详细信息
     */
    @RequiresPermissions("parking:level:query")
    @GetMapping(value = "/{scLevelId}")
    public AjaxResult getInfo(@PathVariable("scLevelId") Integer scLevelId)
    {
        return success(smartLevelService.selectSmartLevelByScLevelId(scLevelId));
    }

    /**
     * 新增楼层管理
     */
    @RequiresPermissions("parking:level:add")
    @Log(title = "楼层管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SmartLevel smartLevel)
    {
        return toAjax(smartLevelService.insertSmartLevel(smartLevel));
    }

    /**
     * 修改楼层管理
     */
    @RequiresPermissions("parking:level:edit")
    @Log(title = "楼层管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SmartLevel smartLevel)
    {
        return toAjax(smartLevelService.updateSmartLevel(smartLevel));
    }

    /**
     * 删除楼层管理
     */
    @RequiresPermissions("parking:level:remove")
    @Log(title = "楼层管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{scLevelIds}")
    public AjaxResult remove(@PathVariable Integer[] scLevelIds)
    {
        return toAjax(smartLevelService.deleteSmartLevelByScLevelIds(scLevelIds));
    }
}
